#!/usr/bin/node

const cp = require('child_process');

console.log('PID:', process.pid);

let cat = cp.spawn('cat', ['data.txt']);
let sort = cp.spawn('sort');
let uniq = cp.spawn('uniq');
//子进程的流连接到父进程的标准输出
cat.stdout.pipe(sort.stdin);
sort.stdout.pipe(uniq.stdin);
uniq.stdout.pipe(process.stdout);

